﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $configs['title']; ?></title>
</head>
<link href="css/tool.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src='js/jquery-1.2.6.min.js'></script>
<body>
<br />
<form name="urlform" action="" method="POST">	
	<table width="400" align="left" cellpadding="0" cellspacing="0" id="myTable">
		<tr>
			<th colspan="3">主数据库选择 [<a href="index.php?act=logout">退出</a>]</th>
		</tr>
		<tr>
			<td colspan="3">&nbsp;&nbsp;<select id='maindb'>
			<option value="0">请选择主数据库</option>
			<?php
			    foreach ($g_db_conf[$version] as $key => $value){
			    	echo "<option value={$key}>",$key,'服务器数据库</option>';
			    }
			?>			
			</select>&nbsp;
			<b>	<?=$_SERVER['SERVER_NAME'];	?>版本</b></td>
		</tr>
		<tr>
			<th colspan="3">对比数据库选择</th>
		</tr>
		<tr>
			<td colspan="2">域名  <select id='domain' onchange="changek();">
			<option value="0">请选择</option>
			<?php
			    foreach ($g_db_conf as $key => $value){
			    	echo "<option value={$key}>",$key,'</option>';
			    }
			?>				
			</select></td>
			<td>服务器名  
			<select id='dbId'>
				<option value="0">请选择对比据库</option>
				<!--<?php
				foreach ($g_db_conf as $key => $value){
					foreach ($value as $k => $val){
						echo "<option value={$k}>",$k,'服务器数据库</option>';
					}
				}
				?>	-->		
			</select>			
			</td>
		</tr>
		<tr>
			<td colspan="3"><input type="button" value="对比" onclick="compareNet();" /> <input  type="button"  value="返回" onclick="window.location.href='comparedb.php';"/></td>
		</tr>
	</table>
</form>
<div id="viewdb"></div><div id="loaddiv" align="center" style="display:none;"><img src="images/loading.gif"/>正在操作数据库,请稍候...</div>
	
<script type="text/javascript">
function compareNet(){
	var domain = "<?=$configs['domain']?>";
	if ($('#maindb').val() == 0){
		alert('请选择主数据库!');
		return;
	}
	
	var str;
	$.ajax({
		type:'POST',
		async:false,
		url:'ajax/dataget.ajax.php',
		data:'domain='+$('#domain').val()+'&dbId='+$('#dbId').val()+'&dbmainId='+$('#maindb').val(),
		beforeSend:function () {
			$('#loaddiv').show();
		},
		success:function(msg){
			$('#loaddiv').hide();
			$('#viewdb').html(msg);
		}
	});
}

function changek(){	
	$.ajax({
		type:'POST',
		async:false,
		url:'ajax/comparedb.ajax.php',
		data:'act=getk&domain='+$('#domain').val(),
		success:function(msg){
			$('#dbId').html(msg);
		}
	});
}

//同步
function asynNetDb(type, db, main){
	var str="";
	$("[name='dbids_"+db+"'][checked]").each(function(){
		str+=$(this).val()+"|";
	})

	$.ajax({
		type:'POST',
		timeout:180000,	
		async:false,
		url:'ajax/comparedb.ajax.php',
		data:"act="+type+"&tabId="+str+"&dbId="+db+"&dbmainId="+main+"&is_back="+$('#is_back[checked]').val(),
		beforeSend:function () {
			$('#loaddiv').show();
		},
		success:function(msg){
			$('#loaddiv').hide();
			alert(msg);
		},
		error:function(){
			alert('ajax请求错误');
			$('#loaddiv').hide();
			return;
		}
	})
}
</script>
</body>